//
//  Reset.m
//  SoundPill
//
//  Created by 温冬 on 15/5/1.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "Reset.h"

@implementation Reset

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createView];
    }
    return self;
}

- (void)createView
{
    // 关闭按钮
    self.close = [UIButton buttonWithType:UIButtonTypeCustom];
    self.close.frame = CGRectMake(20, 20, 30, 30);
    [self.close setBackgroundImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [self addSubview:self.close];
    
    // 确定按钮
    self.certain = [UIButton buttonWithType:UIButtonTypeCustom];
    self.certain.frame = CGRectMake(self.frame.size.width - 40, 20, 30, 30);
    [self.certain setBackgroundImage:[UIImage imageNamed:@"done"] forState:    UIControlStateNormal];
    [self addSubview:self.certain];
    
    // logo
    UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 60, self.frame.size.width, self.frame.size.width * 0.3125)];
    logoImageView.image = [UIImage imageNamed:@"smallLogo.png"];
    [self addSubview:logoImageView];

    
    // 验证码
    self.securityCode = [[UITextField alloc] initWithFrame:CGRectMake(25, logoImageView.frame.size.height + logoImageView.frame.origin.y + 10, (self.frame.size.width - 55) / 2, 35)];
    self.securityCode.placeholder = @"输入验证码";
    self.securityCode.textColor = [UIColor blackColor];
    self.securityCode.textAlignment = NSTextAlignmentCenter;
    self.securityCode.backgroundColor = [UIColor whiteColor];
    [self.securityCode setValue:[UIColor colorWithRed:200 / 255.0 green:201 / 255.0 blue:202 / 255.0 alpha:1.0]forKeyPath:@"_placeholderLabel.textColor"];
    self.securityCode.layer.cornerRadius = 2;
    _securityCode.layer.borderColor = [[UIColor blackColor] CGColor];
    _securityCode.layer.borderWidth = 2;
    self.securityCode.layer.masksToBounds = YES;
    self.securityCode.returnKeyType = UIReturnKeyDone;
    [self addSubview:self.securityCode];
    
    //倒计时显示
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_securityCode.frame.size.width + _securityCode.frame.origin.x + 5, _securityCode.frame.origin.y, (self.frame.size.width - 55) / 2, 35)];
    [self.timeLabel setBackgroundColor:[UIColor blackColor]];
    [self.timeLabel setTextColor:[UIColor whiteColor]];
    self.timeLabel.layer.cornerRadius = 2;
    self.timeLabel.layer.masksToBounds = YES;
    [self addSubview:self.timeLabel];
    
    //获取验证码
    self.timeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.timeButton.frame = CGRectMake(_securityCode.frame.size.width + _securityCode.frame.origin.x + 5, _securityCode.frame.origin.y, (self.frame.size.width - 55) / 2, 35);
    [self.timeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    self.timeButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
    self.timeButton.backgroundColor = [UIColor colorWithRed:30/ 255.0 green:144 / 255.0 blue:255 / 255.0 alpha:1.0];
    self.timeButton.hidden = YES;
    self.timeButton.layer.cornerRadius = 2;
    self.timeButton.layer.masksToBounds = YES;
    [self addSubview:self.timeButton];
    
    //密码
    self.password = [[CustomRegister alloc] initWithFrame:CGRectMake(25, _securityCode.frame.origin.y + _securityCode.frame.size.height + 5, self.frame.size.width - 50, 35) image:[UIImage imageNamed:@"password@3x"] placeHold:@"输入新密码"];
    self.password.field.secureTextEntry = YES;
    self.password.field.returnKeyType = UIReturnKeyDone;
    [self addSubview:self.password];

}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
